package com.menghao.sso.server.model.ticket;

import com.menghao.sso.server.model.validation.Authentication;
import com.menghao.sso.server.registry.ExpirationPolicy;
import com.menghao.sso.server.model.Service;

public interface ServiceTicket extends Ticket {

    /**
     * 应用于生成唯一标识的前缀.
     */
    String PREFIX = "ST";

    /**
     * 返回Ticket授予的Service
     */
    Service getService();

    /**
     * 判断该ST是否随TGT一起创建（即登录成功时）
     */
    boolean isFromNewLogin();

    /**
     * 设置fromNewLogin标志位
     */
    void setFromNewLogin(boolean fromNewLogin);

    /**
     * 为身份授权
     *
     * @param id             Ticket的ID.
     * @param authentication 待授权（Ticket）的身份.
     * @return The ticket granting ticket.
     */
    TicketGrantingTicket grantTicketGrantingTicket(String id, Authentication authentication, ExpirationPolicy expirationPolicy);
}
